package com.victor9ac.mashup.elasticsearch.converter;

import com.victor9ac.mashup.api.Commentaries;
import com.victor9ac.mashup.api.Images;
import com.victor9ac.mashup.api.MashupDataType;
import com.victor9ac.mashup.api.travel.Travel;

public class ElasticSearchConverterFactory {

	static ElasticSearchConverter elasticSearchConverter;

	public ElasticSearchConverterFactory() {
		super();
	}

	public static ElasticSearchConverter buildConverter(Object obj) {

		if (obj instanceof Commentaries) {
			elasticSearchConverter = new ElasticSearchCommentConverter();
		} else if (obj instanceof Images) {
			elasticSearchConverter = new ElasticSearchImagesConverter();

		} else if (obj instanceof Travel) {
			elasticSearchConverter = new ElasticSearchTravelConverter();
		} else {
			throw new RuntimeException("cannot instantiate object, "
					+ obj.toString());
		}

		return elasticSearchConverter;

	}

	public static ElasticSearchConverter buildConverter(
			MashupDataType mashupDataType) {

		if (MashupDataType.COMMENTS.equals(mashupDataType)) {
			elasticSearchConverter = new ElasticSearchCommentConverter();
		} else if (MashupDataType.IMAGES.equals(mashupDataType)) {
			elasticSearchConverter = new ElasticSearchImagesConverter();
		} else {
			throw new RuntimeException("cannot instantiate object, "
					+ mashupDataType.name());
		}

		return elasticSearchConverter;

	}

}
